/**
 * Created by IntelliJ IDEA.
 * User: ryan
 * Date: Sep 15, 2010
 * Time: 1:57:45 PM
 * To change this template use File | Settings | File Templates.
 */
var meeting = meeting || {};

meeting.toMeeting = function(doc, db) {
    var result = {};
    result.startDate = this.getStartDate(doc);
    result.readableStartDate = this.getReadableDate(result.startDate);

    result.endDate = this.getEndDate(doc);
    if (result.endDate) {
        result.readableEndDate = this.getReadableDate(result.result.endDate);
    }

    return result;
}

meeting.getStartDate = function(doc) {
    if (doc['-Recording'] && doc['-Recording']['-startTime']) {
        return new Date (doc['-Recording']['-startTime']);
    }
}


meeting.getReadableDate = function(date) {
        return date.toString('d MMMM yyyy, h:ss tt');
}

meeting.getEndDate = function(doc) {
    if (doc['-Recording'] && doc['-Recording']['-endTime']) {
        return new Date (doc['-Recording']['-endTime']);
    }
}

meeting.ui = meeting.ui || {};

meeting.ui.newMeeting = function(div) {
    var d = $(div);
    d.empty(); // prepare the div. clear anything there
    var form = $('<form id="currentForm">')
            .css('margin-left', '0px')
            .append('<input type="text" id="entry" name="entry" />');
    d.append(form);

    var rootSubtopic = $('<div class="rootCreateSubtopic ">')
            .append('<img class="blur" src="images/actions/light.grey.list-add.png" alt="Start New Topic" title="Start New Topic"/>');
    d.append(rootSubtopic);

    /** All items with blur as a class will have a 'focus' effect on mosue over */
    var lastBlurSource;
    $('.blur')
        .live('mouseover', function() {
            lastBlurSource = $(this).attr('src');
            var src = lastBlurSource.replace("light.", "");
            $(this).attr('src', src);
        })
        .live('mouseout', function() {
            $(this).attr('src', lastBlurSource);
        });

    


}